home *** CD-ROM | disk | FTP | other *** search
- #include <graphics.h>
- #include <stdlib.h>
-
- main()
- {
- int graphdriver = DETECT, graphmode;
- int maxcolor, color, pattern;
- char buffer1[80], buffer2[80];
-
- /* Initialize the graphics system */
- initgraph(&graphdriver, &graphmode, "c:\\turboc");
- /* Now keep switching background colors randomly */
- maxcolor = getmaxcolor();
- /* Initialize random number generator */
- randomize();
- outtextxy(10,20, "Demonstrating setfillstyle");
- outtextxy(10,30, "Press any key to exit");
- while (!kbhit())
- {
- color = random(maxcolor);
- pattern = random(11);
- setfillstyle(pattern, color);
- bar(50,50, 150,100);
- sprintf(buffer1, "Fill color %2d", pattern);
- /* Erase the area where color number will be shown */
- setfillstyle(EMPTY_FILL, color);
- bar(50,100, 50+textwidth(buffer1), 100+3*textheight("H"));
- outtextxy(50,100+textheight("H"), buffer1);
- outtextxy(50,100+2*textheight("H"), buffer2);
- delay(1000); /* Pause for 1 second */
- }
- /* Wait for 1 second, then exit */
- delay(1000);
- closegraph();
- }